export function set16ToRGBNormalized(str:string): [number, number, number] {
  if (str.startsWith("#")) {
    str = str.slice(1);
  }
  if (str.length !== 6) {
    throw new Error("Invalid hex color string");
  }
  const r = parseInt(str.slice(0, 2), 16);
  const g = parseInt(str.slice(2, 4), 16);
  const b = parseInt(str.slice(4, 6), 16);
  return [r / 255, g / 255, b / 255];
}

export function setRGBTo16(r: number, g: number, b: number): string {
  const hexR = r.toString(16).padStart(2, '0');
  const hexG = g.toString(16).padStart(2, '0');
  const hexB = b.toString(16).padStart(2, '0');
  return `#${hexR}${hexG}${hexB}`;
}